﻿<?xml version="1.0" encoding="utf-8" ?>
<FieldTypes>
  <FieldType>
    <Field Name="TypeName">Map</Field>
    <Field Name="ParentType">Text</Field>
    <Field Name="TypeDisplayName">GPM.Fields.Map</Field>
    <Field Name="TypeShortDescription">GPM.Fields.Map</Field>
    <Field Name="UserCreatable">TRUE</Field>
    <Field Name="FieldTypeClass">GPM.Fields.Map,GPM.Fields, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cfb82c9ee591f164</Field>
    <Field Name="CAMLRendering">TRUE</Field>
    <RenderPattern Name="DisplayPattern">
      <HTML>
        <![CDATA[<script type="text/javascript">
        (function(){ 
        
            function makeid(s) {
                var text = "";
                var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";

                for( var i=0; i < 5; i++ )
                    text += possible.charAt(Math.floor(Math.random() * possible.length));

                return s + "_" + text;
            }
            
            var randomID = makeid("GPMMap");
            
            
            document.write("<div id=\"" + randomID + "\" style=\"width: 422px; height: 300px;\" >");
            //window[randomID];
            var functionName = 'loadGPMMap_' + Math.floor(Math.random()*1000001);
            window[functionName] = function () {
                var GPMCoordinatesControls = ("]]>
      </HTML>
      <Column HTMLEncode="TRUE" />
      <HTML>
        <![CDATA[") ? "]]>
      </HTML>
      <Column HTMLEncode="TRUE" />
      <HTML>
        <![CDATA[".split(";") : [55.763645,37.617719,12];
                var latitude = (GPMCoordinatesControls[0]) ? GPMCoordinatesControls[0] : 55.763645;
                var longitude = (GPMCoordinatesControls[1]) ? GPMCoordinatesControls[1] : 37.617719;
                var height = (GPMCoordinatesControls[2]) ? GPMCoordinatesControls[2] : 12;

                window[makeid("GPMMap")] = new ymaps.Map(randomID, {
                    center: [latitude, longitude],
                    zoom: height
                });
            }

            ymaps.ready(window[functionName]);
      })();
      ]]>
      </HTML>
      <HTML><![CDATA[</script>]]></HTML>
      <HTML><![CDATA[</div>]]></HTML>
    </RenderPattern>
  </FieldType>
</FieldTypes>
